package com.atao.baokede.task;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class OrderTask {
    @Autowired
    private RedisTemplate redisTemplate;

    //在每天凌晨0点将Redis中的"lastOrderId"值重置为1。
    @Scheduled(cron = "0 0 0 * * ?")
    public void refreshLastOrderId() {
        redisTemplate.opsForValue().set("lastOrderId", "1");
    }
}
